import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import Components from 'unplugin-vue-components/vite'
import postCssPxToRem from "postcss-pxtorem"
import { VantResolver } from '@vant/auto-import-resolver';


export default defineConfig({
  server:{
    proxy:{
      '/sph-api':{
        target:'http://sph-h5-api.atguigu.cn/',
        changeOrigin:true,
        rewrite:(path) => path.replace(/^\/sph-api/, '')
      },
      '/wy-api':{
        target:'https://m.you.163.com/',
        changeOrigin:true,
        rewrite:(path) => path.replace(/^\/wy-api/, '')
      },
    }
  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 37.5, // 1rem的大小
          propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
        })
      ]
    }
  },
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),
  ],
})
